package cn.edu.scau.cmi.detect.controller;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import cn.edu.scau.cmi.ema.domain.Crawlerevent;
import cn.edu.scau.cmi.ema.domain.base.CmiPagination;
import cn.edu.scau.cmi.front.controller.FrontCmiEmaController;

@Controller
public class FrontCrawlereventController extends FrontCmiEmaController {
	@RequestMapping(value = "/frontListCrawlerevents", method = {RequestMethod.POST, RequestMethod.GET})
	public ModelAndView frontListCrawlerevents(HttpServletRequest request, @ModelAttribute CmiPagination pagination) {	// TODO Auto-generated method stub
		ModelAndView mav = new ModelAndView();

		pagination = crawlereventPaginationService.updatePagination(request, pagination);
		Set<Crawlerevent> crawlerevents = crawlereventPaginationService.getPaginationCrawlerevents(pagination);

		mav.addObject("crawlerevents", crawlerevents);
		mav.addObject("entityName", "crawlerevent");
		mav.addObject("pagination", pagination);
		mav.setViewName("frontdetect/crawlerevent/frontListCrawlerevents.jsp");
		return mav;
	}
	
	
	@RequestMapping("/frontViewCrawlerevent")
	public ModelAndView frontViewCrawlerevent(@RequestParam Integer crawlereventId) {
		ModelAndView mav = new ModelAndView();
		mav.addObject("crawlerevent", crawlereventDAO.findCrawlereventByPrimaryKey(crawlereventId));
		mav.setViewName("frontdetect/crawlerevent/frontViewCrawlerevent.jsp");
		return mav;
	}
	
}